// L1-049 天梯赛座位分配 (20 分)

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int dw[110]; //队伍数
  bool over[110] = {0};
  for (int i = 1; i <= n; i++)
  {
    cin >> dw[i];
    dw[i] *= 10;
  }
  int k = 1;
  int num = 0;
  vector<int> a[110]; //每个队伍
  while (num < n)
  {
    for (int i = 1; i <= n; i++)
    { //在n个队伍中间循环
      if (a[i].size() < dw[i])
      { //第i个 队伍未填满时
        a[i].push_back(k);
        if (num == n - 1)
          k += 2;
        else
          k++;
      }
      if (a[i].size() == dw[i] && over[i] == 0)
      {
        over[i] = 1;
        num++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
  {
    cout << '#' << i << endl;
    for (int j = 0; j < a[i].size(); j++)
    {
      if (j != 0 && (j + 1) % 10 == 0)
        cout << a[i][j] << endl;
      else
        cout << a[i][j] << " ";
    }
  }
  return 0;
}